package com.gz.mylife.util;

import java.util.List;

import com.zl.smartmall.library.po.KeysBean;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class PrefUtils {

	public static final String pref_name = "config";

	public static String getStrPrefData(Context context,String key,String defValue){

		SharedPreferences sp = context.getSharedPreferences(pref_name, Context.MODE_PRIVATE);
		String result = sp.getString(key, defValue);
		return result;
	}

	public static void setStrPrefData(Context context,String key,String value){
		SharedPreferences sp = context.getSharedPreferences(pref_name, Context.MODE_PRIVATE);
		sp.edit().putString(key, value).commit();
	}
	public static void removeStrPrefData(Context context,String key){
		SharedPreferences sp = context.getSharedPreferences(pref_name, Context.MODE_PRIVATE);
		sp.edit().remove(key).commit();
	}

	public static String[] getString(Context context,String key) {
		String regularEx = "#";
		String[] str = null;
		SharedPreferences sp = context.getSharedPreferences(pref_name, Context.MODE_PRIVATE);
		String values; 
		values = sp.getString(key, ""); 
		str = values.split(regularEx);

		return str;
	}

	public static void setString(Context context,String key, String[] values) {
		String regularEx = "#";
		String str = "";
		SharedPreferences sp = context.getSharedPreferences(pref_name, Context.MODE_PRIVATE);
		if (values != null && values.length > 0) {
			for (String value : values) {
				str += value;
				str += regularEx;
			}
			Editor et = sp.edit();
			et.putString(key, str);
			et.commit();
		}  
	}  

}
